<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
	<style type="text/css">
	   *{
	      margin: 0px;
	      padding: 0px;
	      font-size: 12px;
	   }
	</style>
</head>
<body class="gray-bg">
	<!-- 隐藏域 -->
	<input id="uuid" name="uuid" type="hidden" value="${uuid}"/>
	<input id="tid" name="tid" type="hidden" value="${tid}"/>
	<input id="hid" name="hid" type="hidden" value="${hid}"/>
	<input id="creditPeopleType" name="creditPeopleType" type="hidden" value="${creditPeopleType}"/>
	<input id="zxcxApplyId" name="zxcxApplyId" type="hidden" value="${zxcxApplyId}"/>
	<input id="bigUrl" name="bigUrl" type="hidden" value="${ossPath}"/>
	<!-- 隐藏域 -->
 <div class="container creditbody">
	 <div class="buttonfixedzx">
		<button type="button" class="btn dpbtn_green" onclick="xiz();">下载征信文档</button>
	   	<button type="button" class="btn dpbtn_blue" onclick="reback()">退回修改</button>
	   	<!-- 
	   	<button type="button" class="btn dpbtn_green" onclick="tjback();">提交银行</button>
	   	 -->
	   	 <!-- 
	   	<button type="button" class="btn dpbtn_red"	   onclick="tzback();">停止查询</button>
	   	-->
	   	<button type="button" class="btn dpbtn_red"  onclick="bcback();">保存提交</button>
	 </div>

	 <form class="form-horizontal" id="commentForm">
		 <div class="ibox-content ibox-con">
	            <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table zx-addtable">
	            	<tr>
	            		<td align="right">
							<label class="control-label np">经办部门：</label>
						</td>
	            	
						<td>
							<input   type="text" class="form-control" readonly="readonly" value="${current_user_key.orgName}"/>
						</td>
						
						<td align="right">
							<label class="control-label np">经办人：</label>
						</td>
	            	
						<td>
	                       <input  type="text" class="form-control" readonly="readonly" value="${current_user_key.name}">
						</td>
					</tr>
	            </table>
	            <div class="business-manwife" id="p_label">待查征信人</div>
	            
	            <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table zx-addtable">
	            	<tr>
	            		<td align="right">
							<label class="control-label np">客户姓名：</label>
						</td>
						<td>
							<input id="cus_name" name="cus_name"  type="text" class="form-control" readonly="readonly">
						</td>
						<td align="right">
							<label class="control-label np">身份证：</label>
						</td>
						<td>
	                       <input id="cus_no" name="cus_no"  type="text" class="form-control" readonly="readonly">
						</td>
					</tr>
					<tr>	
						<td align="right">
							<label class="control-label np">角色：</label>
						</td>
						<td>
	                       <input id="credit_people_type" name="credit_people_type"  type="text" class="form-control" readonly="readonly">
						</td>
						<td align="right">
							<label class="control-label np">手机号码：</label>
						</td>
						<td>
	                        <input id="tel1"  name="tel1" type="text" class="form-control" readonly="readonly"/>
						</td>
					</tr>
	            </table>
	            
	            <div id="SHEN_FEN_ZHENG_MING_01">
	            	<div class="business-manwife" id="p_label">主借人</div>
		            <div class="padding-nono padding-nonob">
		    			<div class="zx-addimg">
				        	<ul id="SHEN_FEN_ZHENG_MING"></ul>
		        		</div>
		    		</div>
	            </div>
	           
	           <div id="PEI_OU_SHEN_FEN_ZHENG_MING_01">
	           		<div class="business-manwife" id="p_label">配偶</div>
		            <div class="padding-nono padding-nonob">
		    			<div class="zx-addimg">
				        	<ul id="PEI_OU_SHEN_FEN_ZHENG_MING"></ul>
		        		</div>
		    		</div>
	           </div>
	    		
	    	   <div id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_1_01" class="IMG_DAN_BAO_REN" style="display: none;">
		    	   	<div class="business-manwife" id="p_label">担保人</div>
		            <div class="padding-nono padding-nonob">
		    			<div class="zx-addimg">
				        	<ul id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_1"></ul>
		        		</div>
		    		</div>
	    	   </div>
	    		
	    		<div id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_1_02" class="IMG_DAN_BAO_REN" style="display: none;">
	    			<div class="business-manwife" id="p_label">担保人</div>
		            <div class="padding-nono padding-nonob">
		    			<div class="zx-addimg">
				        	<ul id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_2"></ul>
		        		</div>
		    		</div>
	    		</div>
	    		
	    		<div id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_1_03" class="IMG_DAN_BAO_REN" style="display: none;">
	    			<div class="business-manwife" id="p_label">担保人</div>
		            <div class="padding-nono padding-nonob">
		    			<div class="zx-addimg">
				        	<ul id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_3"></ul>
		        		</div>
		    		</div>
	    		</div>
	    		
	    		<div id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_1_04" class="IMG_DAN_BAO_REN" style="display: none;">
	    			<div class="business-manwife" id="p_label">担保人</div>
		            <div class="padding-nono padding-nonob">
		    			<div class="zx-addimg">
				        	<ul id="DAN_BAO_REN_SHEN_FEN_ZHENG_MING_4"></ul>
		        		</div>
		    		</div>
	    		</div>
	    		
	    		<div class="business-manwife" id="p_label">征信情况</div>
	    		
	    		<div class="bg-white">
		    		<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table zx-addtable">
		            	<tr>
		            		<td align="right">
								<label class="control-label np">征信来源：</label>
							</td>
		            	
							<td>
								<input id="bank_code" name="bank_code"  type="text" class="form-control" readonly="readonly">
							</td>
		
		            		<td align="right">
								<label class="control-label np">起始时间：</label>
							</td>
		            	
							<td>
								 <input id="submitTimeStart"  name="submitTimeStart"  placeholder="开始时间" class="form-control" readonly="readonly"/>
							</td>
							
							<td align="right">
								<label class="control-label np">结束时间：</label>
							</td>
		            	
							<td>
								  <input id="submitTimeEnd" name="submitTimeEnd" placeholder="结束时间" class="form-control" readonly="readonly"/>
							</td>
						</tr>
		            </table>
		            
		            <table class="selectcheck ">
			            <tr>  
				            <td><label class="control-label np">开卡状态：</label></td>  
				            <td>  
				                <label><input type="checkbox" value="01" name="junwu" id="junwu" checked="checked" onclick="zxJunWu();"/>均无</label>  
				                <label><input type="checkbox" value="02" name="once_car_status" id="cengyou" onclick="zxyzt();"/>曾有灰名单</label>  
				                <label><input type="checkbox" value="03" name="once_car_status" id="xianyou" onclick="zxyzt();"/>现有灰名单</label>  
				                <label><input type="checkbox" value="04" name="once_car_status" id="waibu" onclick="zxyzt();"/>外部欺诈客户</label>
				                <label><input type="checkbox" value="05" name="once_car_status" id="weiyue" onclick="zxyzt();"/>交叉违约</lable>  
				            </td>  
				        </tr>  
		            </table>
		            
		            <table class="selectcheck clear-both">
		            	<tr>
		            		<td align="right">
								<label class="control-label np">征信状态：</label>
							</td>
							<td>
								<label><input type="radio" name="credit_result" value="01"  id="zhengc" checked="checked">正常</label>
								<label><input type="radio" name="credit_result" value="02" id="guanzhu">关注</label>
								<label><input type="radio" name="credit_result" value="03"  id="jingru">禁入</label>
							</td>
		            	</tr>
		            </table>
		            
		             <ul class="zxsearch-ulc clear-both">
		            	<li class="zxsearch-ulli">信息备注：</li>
		            	<li class="zxsearch-ullib">
							<textarea class="form-control select-control-tebie" id="gcr_remarks" rows="4" name="gcr_remarks" ></textarea>
						</li>
		            </ul>
				</div>
	      </form>      
	  </div>
 
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>

    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    
    <!-- summernote -->
 	<%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>
 	
 	<!-- 文件上传 -->
	<%@include file="/jsp/common_fileupload_include.jsp"%>
 	
	<script type="text/javascript">

		var winWidth = $(window).width();
		var winHeight = $(window).height();
		var dataDictionaryVo = "";
		var index = 0;
		var credit_People_Type = "";
		
		var zxJunWu = function()
		{
			
			var standard = $('input[name="junwu"]:checked').val();
			if(standard == "01")
			{
				 $("input[name=once_car_status]").attr("checked", false);  
			}
		}
		
		var zxyzt = function()
		{
			var b = false;
			var once_car_status = document.getElementsByName("once_car_status");
			for(var i=0;i<once_car_status.length;i++)
			{
				if(once_car_status[i].checked)
				{
					$("input[name=junwu]").attr("checked", false); 
					b = true;
					break;
				}
			}
			if(b == false)
			{
				document.getElementsByName("junwu")[0].checked = true;
			}
		}
		
		
		jQuery(function($){
	
			var date = new Date();
	    	document.getElementById("submitTimeStart").value = date.format("yyyy-MM-dd");
		    getinit();
		});
		
		
		var getinit = function()
		{
			var id = $.getUrlData("tid");
			$.dpAjax({
		   		url:'${basePath}/YwShenQingZxController/getEntityService',
		   		data:{id:id},
				success: function(datas){
			 	  if(datas.flag == "100100"){
			 		
			 		  var d = datas.zxQueryFkVo;
			 		  document.getElementById("cus_name").value = d.cusName;
			 		  document.getElementById("cus_no").value = d.cusNo;
			 		  document.getElementById("tel1").value = d.tel1;
			 		  var power_type = "";
			 		  if(d.creditPeopleType == 01)
			 		  {
			 			 power_type = "配偶";
			 		  }
			 		  else if(d.creditPeopleType == 02)
			 		  {
				 			 power_type = "担保人";
				 	  }
			 		  else
			 		  {
			 			 power_type = "主借人";
			 		  }
			 		  document.getElementById("credit_people_type").value = power_type;
			 		  document.getElementById("bank_code").value = d.bankCode;
			 		  dataDictionaryVo = datas.creditReturnedReason_Result;
			 		  
			 		  var creditPeopleType = $('#creditPeopleType').val();
			 		  if(creditPeopleType == "担保人")
			 		  {
			 			  //图片显示
				 		  showAttentment(d.replaceId,'', '${modeIDTypeNames.ZXCX }',d.tid,function(){
				 			 $('.IMG_DAN_BAO_REN').each(function(){
					 			  var imgs = $(this).find('img');
					 			  if(imgs && imgs.length > 0){
					 				  $(this).show();
					 				  credit_People_Type = $(this).attr('id'); 
					 			  }
					 		  }); 
				 		   });
			 		  }
			 		  else
			 		  {
			 			  //图片显示
				 		  showAttentment(d.replaceId,'', '${modeIDTypeNames.ZXCX }','',function(){});
			 		  }
			 		  
			 		  //结束的时间
			 		  $('#submitTimeEnd').val(datas.enddate);
					  return;
				  }
				  if(datas.flag == "100200"){
					  alert(JSON.stringify(datas));
		              return;
		          }
				  layer.msg(datas.message, {icon: 2});
				}
		   	});
		}
	
		
		//提交银行   银行接口没有  暂时不调用
		var tjback = function()
		{
			alert("银行接口没有  暂时不调用！");
			return;
			
			var beg_time2 = document.getElementById("beg_time2").value;
			var end_time2 = document.getElementById("end_time2").value;
			var objs = document.getElementsByName("once_car_status");
			var onceCarStatus = "";
			for(var i=0;i<objs.length;i++)
			{
				if(objs[i].checked)
				{
					onceCarStatus += objs[i].value +",";
				}
			}
			
			if(onceCarStatus != "")
			{
				onceCarStatus = onceCarStatus.substring(0,onceCarStatus.length-1);
			}
			
			var crObjs = document.getElementsByName("credit_result");
			var creditResult = ""; 
			for(var i=0;i<crObjs.length;i++)
			{
				if(crObjs[i].checked)
				{
					creditResult = crObjs[i].value;
					break;
				}
			}
			
			var gcr_remarks = $("#gcr_remarks").val();
			
			var hid = document.getElementById("hid").value;
			
			$.dpAjax({
		   		url:'${basePath}/ZxCreditQueryController/modify',
		   		data:{
		   			"startDate":beg_time2,
		   			"endDate":end_time2,
		   			"creditResult":creditResult,
		   			"onceCarStatus":onceCarStatus,
		   			"id":hid,
		   			"remarks":gcr_remarks
		   		},
				success: function(datas){
			 	  if(datas.flag == "100100"){
			 		  layer.msg("提交银行成功！", {icon: 6});
					  return;
				  }
				  if(datas.flag == "100200"){
					  alert(JSON.stringify(datas));
		              return;
		          }
				  layer.msg(datas.message, {icon: 5});
				}
		   	});
		}
		
		var reback = function()
		{
			var content='<form class="form-horizontal">'
					        +'<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table zxb-addtable">'
						        +'<tr>'
							        +'<td align="right">'
								        +'<label class="control-label np">退回原因：</label>'
								    +'</td>'
								    +'<td>'
								        +'<select id="reason_back" name="reason_back"  class="select-control" >';
									        for(var key in dataDictionaryVo) 
									        {
									        	content += '<option value="'+key+'">'+dataDictionaryVo[key]+'</option>'
									        }
									        content += '</select>'
								    +'</td>'
								+'</tr>'	
								+'<tr>'
								     +'<td align="right" valign="top">'
								        +'<label class="control-label np">退回备注：</label>'
								     +'</td>'	
								     +'<td>'
								        +'<textarea id="credit_result_mark" name="credit_result_mark" cols="50" rows="5" type="text" class="form-control" aria-required="true" placeholder="请输入备注" maxlength="225"></textarea>'
								     +'</td>'
								+'</tr>'
							+'</table>'
							+'<table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8"  width="100%">'
								+'<tr>'
							       +'<td width="100%" align="center">'
								        +'<div class="ibox-content">'
									        +'<button type="button" class="btn dpbtn_green" onclick="Updatesave(); ">确定</button>&nbsp;'
									        +'<button type="button" class="btn dpbtn_red" onclick="Cancel();">取消</button>'
								        +'</div>'
						        	+'</td>'
						        +'</tr>'
					        +'</table>'
			         +'</form>';
			
			index = layer.open({
				  title:'退回修改',
				  type: 1,
				  area: ['450px', '50%'], //宽高
				  content:content,
				}); 
		}
		
		var Cancel= function()
	    {
	    	layer.close(index);
	    }
		
		
		var Updatesave = function()
		{	
			var credit_query_status = 20;
			var query_credit_apply_status = 10;
			
			var beg_time2 = document.getElementById("submitTimeStart").value;
			var end_time2 = document.getElementById("submitTimeEnd").value;
			var objs = document.getElementsByName("once_car_status");
			var onceCarStatus = "";
			for(var i=0;i<objs.length;i++)
			{
				if(objs[i].checked)
				{
					onceCarStatus += objs[i].value +",";
				}
			}
			
			if(onceCarStatus && onceCarStatus != "")
			{
				onceCarStatus = onceCarStatus.substring(0,onceCarStatus.length-1);
			}
			
			var crObjs = document.getElementsByName("credit_result");
			var creditResult = ""; 
			for(var i=0;i<crObjs.length;i++)
			{
				if(crObjs[i].checked)
				{
					creditResult = crObjs[i].value;
					break;
				}
			}
			
			var credit_result_mark = $("#gcr_remarks").val();
			var hid = document.getElementById("hid").value;
			var tid = document.getElementById("tid").value;
			var replaceId = document.getElementById("uuid").value;
			var reason_back = document.getElementById("reason_back").value;
			var remarks = document.getElementById("credit_result_mark").value;
			
			//询问框
			layer.confirm('返回征信信息修改，是否确认执行？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				layer.closeAll();
				$.dpAjax({
			   		url:'${basePath}/YwShenQingZxController/zxUpdateStatusTextService',
			   		data:{
			   			"tid":tid,
			   			"hid":hid,
			   			"replaceId":replaceId,
			   			"query_credit_apply_status":query_credit_apply_status,
			   			"reason_back":reason_back,
			   			"remarks":remarks,
			   			"start_date":beg_time2,
			   			"end_date":end_time2,
			   			"credit_result":creditResult,
			   			"credit_result_mark":credit_result_mark,
			   			"once_car_status":onceCarStatus,
			   			"credit_query_status":credit_query_status
			   		},
					success: function(datas){
				 	  if(datas.flag == "100100")
				 	  {
					 	  layer.msg("退回执行成功！", {icon: 6});
					 	  parent.layer.close(parent.bclayer);
					 	  parent.refresh();
					 	  return;
					  }
					  if(datas.flag == "100200")
					  {
						  alert(JSON.stringify(datas));
			              return;
			          }
					  layer.msg(datas.message, {icon: 5});
					}
			   	});	
				
			}, function(){
				layer.msg("已取消本次操作！", {icon: 6});
			});
		}
		
		//下载
		var xiz = function()
		{
			//询问框
			layer.confirm('下载已就绪，是否确认下载到本地？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				layer.closeAll();
				var bigUrl = $('#bigUrl').val();
				if(bigUrl == "")
				{
					layer.msg("下载附件出错，请联系管理员", {icon: 5});
					return;
				}
				layer.msg("正在尝试下载，请稍后...", {icon: 6});
				setTimeout(function(){window.open(bigUrl);}, 1000);
				
			}, function(){
				layer.msg("已取消本次操作！", {icon: 6});
			});
		}
		
		
		//停止查询
		var tzback = function()
		{
			var credit_query_status = 999;
			var query_credit_apply_status = 20;
			
			var beg_time2 = document.getElementById("beg_time2").value;
			var end_time2 = document.getElementById("end_time2").value;
			var objs = document.getElementsByName("once_car_status");
			var onceCarStatus = "";
			for(var i=0;i<objs.length;i++)
			{
				if(objs[i].checked)
				{
					onceCarStatus += objs[i].value +",";
				}
			}
			if(onceCarStatus != "")
			{
				onceCarStatus = onceCarStatus.substring(0,onceCarStatus.length-1);
			}
			var crObjs = document.getElementsByName("credit_result");
			var creditResult = ""; 
			for(var i=0;i<crObjs.length;i++)
			{
				if(crObjs[i].checked)
				{
					creditResult = crObjs[i].value;
					break;
				}
			}
			var credit_result_mark = $("#gcr_remarks").val();
			var hid = document.getElementById("hid").value;
			var tid = document.getElementById("tid").value;
			var replaceId = document.getElementById("uuid").value;
			
			$.dpAjax({
		   		url:'${basePath}/YwShenQingZxController/zxUpdateStatusTextService',
		   		data:{
		   			"tid":tid,
		   			"hid":hid,
		   			"replaceId":replaceId,
		   			"query_credit_apply_status":query_credit_apply_status,
		   			"start_date":beg_time2,
		   			"end_date":end_time2,
		   			"credit_result":creditResult,
		   			"credit_result_mark":credit_result_mark,
		   			"once_car_status":onceCarStatus,
		   			"credit_query_status":credit_query_status
		   		},
				success: function(datas){
			 	  if(datas.flag == "100100")
			 	  {
				 	  layer.msg("停止执行成功！", {icon: 6});
				 	  layer.closeAll();
				 	  return;
				  }
				  if(datas.flag == "100200")
				  {
					  alert(JSON.stringify(datas));
		              return;
		          }
				  layer.msg(datas.message, {icon: 5});
				}
		   	});
		}

		
		//重复可操作的值
		var saveIndex = 0;
		
		//保存
		var bcback = function()
		{
			if(saveIndex == 1)
			{
				layer.msg("正在提交信息，不可重复操作！", {icon: 6});
				return;
			}
			
			var gcr_remarks = $("#gcr_remarks").val();
			
			if(gcr_remarks.stripHTML() == "")
			{
				layer.msg("备注信息不能为空！", {icon: 5});
				return;
			}
			
			var validstatus = $("#commentForm").valid();
			if(validstatus){
				
				var credit_query_status = 40;
				var query_credit_apply_status = 20;
				
				var beg_time2 = document.getElementById("submitTimeStart").value;
				var end_time2 = document.getElementById("submitTimeEnd").value;
				
				var objs = document.getElementsByName("once_car_status");
				var onceCarStatus = "";
				for(var i=0;i<objs.length;i++)
				{
					if(objs[i].checked)
					{
						onceCarStatus += objs[i].value +",";
					}
				}
				if(onceCarStatus != "")
				{
					onceCarStatus = onceCarStatus.substring(0,onceCarStatus.length-1);
				}
				var crObjs = document.getElementsByName("credit_result");
				var creditResult = ""; 
				for(var i=0;i<crObjs.length;i++)
				{
					if(crObjs[i].checked)
					{
						creditResult = crObjs[i].value;
						break;
					}
				}
				var credit_result_mark = $("#gcr_remarks").val();
				var hid = document.getElementById("hid").value;
				var tid = document.getElementById("tid").value;
				var replaceId = document.getElementById("uuid").value;
				
				
				if(onceCarStatus == "")
				{
					onceCarStatus = "01";  //均无
				}
				
				//询问框
				layer.confirm('是否保存到资料登记，请确认是否执行？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					
					if(saveIndex == 1)
					{
						layer.msg("正在提交信息，不可重复操作！", {icon: 6});
						return;
					}
					
					layer.msg("正在提交中！", {icon: 16,time:1500});
					$.dpAjax({
				   		url:'${basePath}/YwShenQingZxController/creditFeedback',
				   		data:{
				   			"tid":tid,
				   			"hid":hid,
				   			"replaceId":replaceId,
				   			"query_credit_apply_status":query_credit_apply_status,
				   			"start_date":beg_time2,
				   			"end_date":end_time2,
				   			"credit_result":creditResult,
				   			"creditResultMark":credit_result_mark,
				   			"once_car_status":onceCarStatus,
				   			"credit_query_status":credit_query_status
				   		},
						success: function(datas){
						 	  layer.msg("保存执行成功！", {icon: 6});
						 	  parent.layer.closeAll();
						 	  parent.refresh();
						},
						busiReturn :function (datas) {
							saveIndex = 0;
						}
				   	});
				}, function(){
					layer.msg("已取消本次操作！", {icon: 6});
				});
			}	
		}
		
		
		$(function(){
	        $("#commentForm").validate({
	            rules: {
	            	submitTimeStart:{
	            		 required: true,
	            	},
	            	submitTimeEnd:{
	            		 required: true,
	            	},
	            },
	            messages: {
	            	submitTimeStart:{
	            		required: "起始时间必填",
	            	},
	            	submitTimeEnd:{
	                	required: "结束时间必填",
	                },
	            },
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) {$(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        });
		});
</script>
</body>
</html>
